home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 20 / CU Amiga Magazine's Super CD-ROM 20 (1998)(EMAP Images)(GB)[!][issue 1998-03].iso / CDsupport / HippoPlayer / ARexx / TotalDuration.hip < prev    next >
Text File  |  1996-08-17  |  4KB  |  128 lines

  1. /******************************************************/
  2. /*                                                    */
  3. /*   TotalDuration.hip (C) Tomasz Kepa 09.VII.1996    */
  4. /*                                 `                  */
  5. /*   $VER: V1.0                                       */
  6. /*                                                    */
  7. /*     Calculates total duration of modulelist        */
  8. /*                  in HippoPlayer.                   */
  9. /*     The module list shouldn't be empty :-)         */
  10. /*                      Enjoy!                        */
  11. /*                                                    */
  12. /*      Aha, read the doc! (TotalDuration_*.guide)    */
  13. /*                                                    */
  14. /******************************************************/
  15.  
  16. address 'HIPPOPLAYER'
  17. options results
  18.  
  19. parse arg OPTION   /* parse options from command line */
  20.  
  21. if OPTION = '/?' | OPTION = '?' | upper(OPTION) = '-H' | upper(OPTION) = 'HELP' | upper(OPTION) = '-HELP' then
  22.     do
  23.         say
  24.         say 'TotalDuration V1.0 (C) Tomasz Kepa 09.VII.1996'
  25.         say
  26.         say 'This script was written for use with HippoPlayer.'
  27.         say 'It simply counts duration of whole list of modules =)'
  28.         say
  29.         say 'Usage:'
  30.         say
  31.         say 'TotalDuration.hip [SD=ShortDisplay] [ND=NoDisplay]'
  32.         say
  33.         exit
  34.     end
  35.                           /* clear all the variables: */
  36.  
  37. NO = 0                   /* number of modules in list */
  38. CURRENT = 1               /* current position in list */
  39. TOTAL = 0                           /* total duration */
  40. DURATION = 0                /* duration of one module */
  41. HIGH = 0                          /* highest duration */
  42. LOW = 0                            /* lowest duration */
  43. SD = FALSE
  44. ND = FALSE
  45.  
  46. CUP = 'A'                             /* cursor up */
  47.  
  48.  
  49. get NFIL                 /* how many modules in list? */
  50. NO = result
  51.  
  52. if upper(OPTION) = 'SD' | upper(OPTION) = 'SHORTDISPLAY' then SD = TRUE
  53. else
  54. if upper(OPTION) = 'ND' | upper(OPTION) = 'NODISPLAY' then ND = TRUE
  55.  
  56.                    /* the rest is obvious I hope. :-) */
  57.  
  58. if NO = 0 then
  59.     do
  60.         say 'Module list is empty. The duration is 0:00 :-)'
  61.         exit
  62.     end
  63. else
  64. do forever
  65.     choose CURRENT
  66.     play
  67.     get DURA
  68.     DURATION = value(result)
  69.     HIGH = max(HIGH, DURATION)                 /* get the highest */
  70.                                                       /* duration */
  71.     if DURATION ~= 0 then                       /* and the lowest */
  72.         do                                            /* duration */
  73.             if LOW = 0 then LOW = DURATION
  74.             else
  75.             LOW = min(LOW, DURATION)
  76.         end
  77.  
  78.     TOTAL = TOTAL + DURATION
  79.     call CHANGETFORMAT DURATION
  80.     DURF = result
  81.     call CHANGETFORMAT TOTAL
  82.     TOTF = result
  83.     if ND = FALSE then say 'Checking mod nº 'CURRENT' of 'NO'. Duration is 'DURF'; 'TOTF' so far. '100 * CURRENT % NO'% done.'
  84.     if NO < CURRENT + 1 then leave
  85.         else
  86.     if SD = TRUE then say CUP''CUP
  87.     CURRENT = CURRENT + 1
  88. end
  89.  
  90. say
  91. call CHANGETFORMAT TOTAL
  92. say 'Total duration of 'NO' modules is 'result' (that''s exactly 'TOTAL' seconds)'
  93. call CHANGETFORMAT HIGH
  94. HIG = result
  95. call CHANGETFORMAT LOW
  96. LW = result
  97. call CHANGETFORMAT TOTAL % NO
  98. AVG = result
  99. say 'Highest duration: 'HIG', lowest duration: 'LW'. Average: 'AVG
  100. return
  101.  
  102. /*******************************************************/
  103. /*                                                     */
  104. /* A little subroutine that calculates hh:mm:ss format */
  105. /*               having amount of seconds.             */
  106. /*                                                     */
  107. /*******************************************************/
  108.  
  109. CHANGETFORMAT:
  110.     parse arg DURATION    /* parse amount of seconds   */
  111.  
  112.     ZERO = ''             /* clear the variables       */
  113.     HRS = ''              /* to prevent trashing the   */
  114.                           /* subroutine =)             */
  115.  
  116.     MINS = DURATION % 60    /*     integer division    */
  117.     SECS = DURATION // 60   /* remainder from division */
  118.     HOURS = MINS % 60
  119.  
  120.     if SECS < 10 then ZERO = '0'  /* MM:0S happens :-) */
  121.     if MINS >= 60 then MINS = MINS - (HOURS * 60)
  122.     if HOURS ~= 0 then
  123.         do
  124.             HRS = HOURS':'
  125.             if MINS < 10 then HRS = HRS'0'
  126.         end
  127.     return HRS''MINS':'ZERO''SECS
  128.